/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ELE.EnterpriseLibrary.Naming;

namespace ELE.EnterpriseLibrary.Test
{
  [TestClass]
  public class DependencyInjectionTestFixture : BaseFixture
  {
    /// <summary>
    /// This test method is used to test the functionality of the default context of type <see cref="INamingContext"/> created by using
    /// the default manager from the <see cref="NamingContextFactory"/>.
    /// </summary>
    [TestMethod]
    public void TestDefaultContext()
    {
      try
      {
        INamingContext ctx = NamingContextFactory.CreateContext();
        object o = ctx.Lookup("/ELE/Test/Employee");
        //Console.WriteLine(o.GetType().FullName + " = " + o.ToString());
        ctx = NamingContextFactory.CreateContext();
        INamingContext subCtx = ctx.GetSubcontext("Initial");

        object db = ctx.Lookup("/ELE/Test/Database");
        Console.WriteLine(db.GetType());

        IContextRemotingObject cro = (IContextRemotingObject)ctx.GetSubcontext("Remote").LookupLink("Remoting/ContextRemotingObject");
        string response = cro.SayHello("Juan");
        Console.WriteLine(response);
      }
      catch (Exception e)
      {
        Console.WriteLine(e.StackTrace);
        Assert.Fail("Test Failed due to : " + e.Message);
      }

    }
  }
}
